package com.etc.myblog.biz;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.etc.myblog.dao.PowerDao;
import com.etc.myblog.entity.Power;
import com.etc.myblog.util.SessionFactoryUtil;

public class PowerBiz {
	public List<Power> find(){
		List<Power> list = new ArrayList<Power>();
		SqlSession session = SessionFactoryUtil.getSession();
		try{
		  PowerDao dao = session.getMapper(PowerDao.class);
			list = dao.find();
		}catch(Exception e){
			System.out.println(e.getMessage());
		}finally{
			session.close();
		}
		
		return list;
	}
	public Power findPowBypowId(int powerId){
		Power pow = new Power();
		SqlSession session = SessionFactoryUtil.getSession();
		try{
			PowerDao dao = session.getMapper(PowerDao.class);
			pow = dao.findPowBypowId(powerId);
		}catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			session.close();
		}
		return pow;
	}
}
